package bizlogic;

import java.util.ArrayList;
import java.util.Date;

import model.PublicHolidayDTO;
import dao.DAOException;
import dao.DAOFactory;
import dao.PublicHolidayDAO;


public class PublicHolidayManager {
	private PublicHolidayDAO publicholidayDAO;

	public PublicHolidayManager() {
		publicholidayDAO = DAOFactory.loadInstance().getPublicHolidayDAO();
	}

	@SuppressWarnings("finally")
	public PublicHolidayDTO findPublicHoliday(Date date) {
		PublicHolidayDTO currentPublicHoliday = new PublicHolidayDTO();
		try {
			currentPublicHoliday = publicholidayDAO.findPublicHoliday(date);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			return currentPublicHoliday;
		}

	}

	@SuppressWarnings("finally")
	public ArrayList<PublicHolidayDTO> findAllPublicHoliday() {
		ArrayList<PublicHolidayDTO> currentList = new ArrayList<PublicHolidayDTO>();
		try {
			currentList = publicholidayDAO.findAllPublicHoliday();
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		} finally {
			return currentList;
		}
	}
	
	public void addPublicHoliday(PublicHolidayDTO holiday) throws DAOException{
		try {
		publicholidayDAO.addPublicHoliday(holiday);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
	public void updatePublicHoliday(PublicHolidayDTO holiday) throws DAOException{
		try {
		publicholidayDAO.updatePublicHoliday(holiday);
		} catch (DAOException e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
	}
}
